/*******************************************************************************
**
** Copyright (c) 2011 - The OWE Team
**
** This file is part of OWE.
**
** OWE is a free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; version
** version 2.1 of the License.
**
** OWE is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with OWE. If not, see <http://www.gnu.org/licenses/>.
**
*******************************************************************************/

#ifndef ELEMENT_H
#define ELEMENT_H

#include <owe/global.h>
#include <owe/ustring.h>

OWE_BEGIN_NAMESPACE

class Node;
class TextElement;

class OWE_EXPORT Element
{
public:
    enum ElementType {
        None,
        Widget,
        Name,
        Description,
        Author,
        Feature,
        Preference,
        Param,
        License,
        Content,
        Icon,
        Text
    };

    static Element *fromNode(const Node *node);
    virtual ~Element();

    virtual bool addChild(Element *element);

    virtual bool addText(TextElement *element);

    ElementType type() const { return m_type; }

    UString lang() const { return m_lang; }
    UString dir() const { return m_dir; }
    UString text() const { return m_text; }

protected:
    Element(const Node *node, ElementType type = None);

    ElementType m_type;

    UString m_lang;
    UString m_dir;
    UString m_text;
};

inline std::ostream &operator<<(std::ostream &left, const Element *right)
{
    return left << right->text();
}

OWE_END_NAMESPACE

#endif // ELEMENT_H
